package com.santana.parser;

import org.apache.log4j.Logger;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.Query;
import org.apache.lucene.util.Version;

public class QueryCreator {

	private static Logger log = Logger.getLogger(QueryCreator.class);

	public static Query create(String query, String field) {

		Query q = null;

		log.info("Create query "+query+" to "+field);
		
		try {
			q = new QueryParser(Version.LUCENE_44, field, Lucene.analyzer)
					.TopLevelQuery(query);

		} catch (Exception e) {
			log.error(e);
		}

		return q;
	}

}
